import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:share_fit/app/helper/ext/tr_ext.dart';
import 'package:share_fit/app/tools/color_const.dart';
import 'package:share_fit/generated/locales.g.dart';

class UpdateDialog extends Dialog {

  final String newVersion;
  final String updateDes;
  final Function callback;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
        child: Material(
            type: MaterialType.transparency,
            child: Center(
                child: GestureDetector(
                    onTap: () {
                      print('～');
                    },
                    child: Container(
                        width: 916.w,
                        height: 1000.w,
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(10),
                          color: Colors.white,
                        ),
                      child: Column(
                        children: [
                          Container(
                            margin: EdgeInsets.only(top: 79.h),
                            child: Text(LocaleKeys.firmware_new_version.ts, style: TextStyle(color: ColorConst.btnFontColor, fontSize: 54.sp),),
                          ),
                          Container(
                            margin: EdgeInsets.only(top: 20.h),
                            child: Text(newVersion, style: TextStyle(color: ColorConst.secondaryFontColor, fontSize: 42.sp),),
                          ),
                          Container(
                            margin: EdgeInsets.only(top: 79.h),
                            child: Text(updateDes, style: TextStyle(color: ColorConst.btnFontColor, fontSize: 46.sp),),
                          ),
                          Spacer(),
                          GestureDetector(
                              behavior: HitTestBehavior.opaque,
                              child: Container(
                                  width: 916.w,
                                  height: 136.h,
                                  margin: EdgeInsets.only(left: 100.w, right: 100.w),
                                  alignment: Alignment.center,
                                  decoration: BoxDecoration(
                                    color: ColorConst.accentColor,
                                    borderRadius: BorderRadius.circular(10),
                                  ),
                                  child: Text(
                                      LocaleKeys.upgrade.ts,
                                      textAlign: TextAlign.center,
                                      style: TextStyle(color: Colors.white, fontSize: 54.sp, fontWeight: FontWeight.w400)
                                  )
                              ),
                              onTap: () {
                                callback(0);
                                Navigator.pop(context);
                              }),
                          GestureDetector(
                              behavior: HitTestBehavior.opaque,
                              child: Container(
                                  width: 916.w,
                                  height: 136.h,
                                  margin: EdgeInsets.only(left: 100.w, right: 100.w),
                                  alignment: Alignment.center,
                                  decoration: BoxDecoration(
                                    color: Colors.transparent,
                                    borderRadius: BorderRadius.circular(10),
                                  ),
                                  child: Text(
                                      LocaleKeys.ignore.ts,
                                      textAlign: TextAlign.center,
                                      style: TextStyle(color: ColorConst.btnFontColor, fontSize: 46.sp, fontWeight: FontWeight.w400)
                                  )
                              ),
                              onTap: () {
                                callback(1);
                                Navigator.pop(context);
                              }),
                        ],
                      ),
                    )))),
        onTap: () {
          Navigator.pop(context);
        }
    );
  }

  UpdateDialog({required this.newVersion, required this.updateDes, required this.callback}); // 内容
}